Skip to content

01-FP-Basics

Basic Expressions

Standard Out

ocaml
print_endline "Hello World!";;

For other data type,print_char,print_float,print_int, etc.

Declaration

  • let is used for declarations.
ocaml
let <name> = <expression>;;
  • let - initiative a declaration.
  • <name> - a new name (for variable, functions, etc.) being declared, which must start with lower letter;
  • <expression> - the value of the name.

Example:

ocaml
let x = 4005;;

Return:

ocaml
val x : int = 4005